package gererg;

/**
 * @author leon(liangzou0318@gmail.com)
 * @date 2012-12-7
 * @filaname SubSet.java
 */
public class SubSet {
     static void subset(int m,int a[],int[] b){
    	 for(int i=0;i<5;i++){
    		 int temp=0;
    		 int k=0;
    		 System.out.println("#######"+a[i]+" m "+m);
    		 if(temp+a[i]==m){
    			 b[k]=i;
    			 for(int j=0;j<k;j++){
    				 System.out.print(b[j]+"  ");
    			 }
    		 }
    		 else if(temp+a[i]<m){
    			 System.out.println(" heher "+m);
    			 temp=temp+a[i];
    			 b[k++]=i;
    			 System.out.println(" bk "+b[k-1]+" i "+i+" temp: "+temp+"  subset("+ (m-temp) +")");
    			 subset(m-temp,a,b);
    		 }	
    		
    //		 else{subset(m,a,b);}
    	//	 } 
    	 }
     }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
        int m=35;// 和
        int[] a=new int[]{9,12,14,21,23};
        int[] b=new int[5];
   //     int k=0;
        System.out.println("Start");
        subset(m,a,b);
        System.out.println("End");
        
	}

}
